package com.fivefu.core.skyeye.event.controller;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fivefu.base.web.controller.BaseController;
import com.fivefu.base.web.vo.ResultInfo;
import com.fivefu.core.skyeye.event.services.DbAiEventFailedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 事件错误日志表 前端控制器
 * </p>
 *
 * @author 
 * @since 2022-08-26 16:57:06
 */
@Api(tags = "事件错误日志")
@RestController
@RequestMapping("/dbAiEventFailed")
public class DbAiEventFailedController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(DbAiEventFailedController.class);

    @Resource
    private DbAiEventFailedService dbAiEventFailedService;

    @ApiOperation(value = "获取事件错误日志列表(分页请传limit和page)",httpMethod = "POST",response = ResultInfo.class,notes = "获取事件错误日志列表(分页请传limit和page)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页(分页查询时必填)",paramType = "query",required = false, dataType = "int"),
            @ApiImplicitParam(name = "limit",value = "每页显示条数(分页查询时必填)",paramType = "query",required = false, dataType = "int"),
            @ApiImplicitParam(name = "cameraid",value = "探头编号",paramType = "query",required = false, dataType = "String"),
            @ApiImplicitParam(name = "sceneid",value = "场景编号",paramType = "query",required = false,dataType = "String")
    })
    @RequestMapping(path = "/queryAiEventFailedList",method = RequestMethod.POST)
    public ResultInfo queryAiEventFailedList(Integer page,Integer limit,String cameraid,String sceneid) {
        logger.info("获取事件错误日志列表接收的参数："+ JSON.toJSONString(request.getParameterMap()));
        try {
            Page<Map<String, Object>> result = dbAiEventFailedService.queryAiEventFailedList(page,limit,cameraid,sceneid);
            return ResultInfo.renderSuccess(result);
        } catch (Exception e) {
            logger.error(e.getMessage(),e);
        }
        return   ResultInfo.renderError("获取事件错误日志列表失败");
    }
}
